package com.health.healthSys.controller;

import com.health.common.annotation.Log;
import com.health.common.core.controller.BaseController;
import com.health.common.core.domain.AjaxResult;
import com.health.common.enums.BusinessType;
import com.health.healthSys.service.IHealthInfoLikeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * 资讯点赞Controller
 */
@RestController
@RequestMapping("/healthSys/like")
public class HealthInfoLikeController extends BaseController {
    @Autowired
    private IHealthInfoLikeService healthInfoLikeService;

    /**
     * 点赞资讯
     */
    @PostMapping("/{infoId}")
    public AjaxResult like(@PathVariable("infoId") Long infoId) {
        return toAjax(healthInfoLikeService.likeInfo(infoId, getUserId()));
    }

    /**
     * 取消点赞
     */
    @DeleteMapping("/{infoId}")
    public AjaxResult unlike(@PathVariable("infoId") Long infoId) {
        return toAjax(healthInfoLikeService.unlikeInfo(infoId, getUserId()));
    }

    /**
     * 检查用户是否已点赞
     */
    @GetMapping("/check/{infoId}")
    public AjaxResult checkLike(@PathVariable("infoId") Long infoId) {
        return AjaxResult.success(healthInfoLikeService.checkLikeStatus(infoId, getUserId()));
    }

    /**
     * 获取资讯点赞数
     */
    @GetMapping("/count/{infoId}")
    public AjaxResult getLikeCount(@PathVariable("infoId") Long infoId) {
        return AjaxResult.success(healthInfoLikeService.getLikeCount(infoId));
    }
} 